load("//bazel:skia_rules.bzl", "skia_cc_library")
load("//tools/testrunners/unit:android_unit_test.bzl", "android_unit_test")
load("//tools/testrunners/unit:unit_tests.bzl", "unit_tests")
load(
    ":testgroups.bzl",
    "CORE_TESTS",
    "RECORD_TESTS",
)

skia_cc_library(
    name = "test_type",
    hdrs = ["TestType.h"],
    visibility = ["//tools/gpu:__pkg__"],
)

skia_cc_library(
    name = "test_harness",
    testonly = True,
    srcs = [
        "CtsEnforcement.cpp",
        "Test.cpp",
        "TestHarness.cpp",
        "//tools:Registry.h",
        "//tools/flags:CommandLineFlags.cpp",
        "//tools/flags:CommandLineFlags.h",
    ],
    hdrs = [
        "CtsEnforcement.h",
        "Test.h",
        "TestHarness.h",
        "TestType.h",
    ],
    visibility = ["//tools/testrunners/unit:__pkg__"],
    deps = [
        "//:core",
        "//src/base",
    ],
)

skia_cc_library(
    name = "tests_base",
    testonly = True,
    srcs = [
        "//tools:Registry.h",
        "//tools:ResourceFactory.h",
        "//tools:Resources.cpp",
        "//tools:SkMetaData.cpp",
        "//tools:SkMetaData.h",
        "//tools:ToolUtils.cpp",
        "//tools/fonts:test_font_manager_srcs",
    ],
    hdrs = [
        "//tools:Resources.h",
        "//tools:ToolUtils.h",
        "//tools/flags:CommandLineFlags.h",
        "//tools/fonts:test_empty_typeface",
    ],
    textual_hdrs = [
        "//tools/fonts:test_fonts",
    ],
    deps = [
        "//:core",
        "//src/base",
    ] + select({
        "@platforms//os:android": ["//:fontmgr_android_freetype"],
        "@platforms//os:linux": ["//:fontmgr_fontconfig_freetype"],
        # TODO(kjlubick) mac, windows
        "//conditions:default": ["//:fontmgr_empty"],
    }),
)

unit_tests(
    name = "core_tests",
    resources = [
        "//resources:core_test_resources",
    ],
    tests = CORE_TESTS,
    deps = [
        ":tests_base",
        "//:core",
    ],
)

unit_tests(
    name = "record_tests",
    extra_srcs = ["RecordTestUtils.h"],
    tests = RECORD_TESTS,
    deps = [
        ":tests_base",
        "//:core",
    ],
)

# The set of all tests that can be compiled on Linux RBE
test_suite(
    name = "linux_rbe_tests",
    tests = [
        ":core_tests",
        ":record_tests",
    ],
)

android_unit_test(
    name = "android_math_test",
    srcs = ["MathTest.cpp"],
)
